import java.awt.Color;
import java.awt.*;
public class Block {
	Location loc;
	Grid gr;
	Color color;
	Graphics2D g;
	int xCoord;
	int yCoord;

	
	public Block(Color color,Grid grid,Location loc){
		this.gr=grid;
		this.color=color;
		this.loc=loc;
		xCoord=loc.getXCoord();
		yCoord=loc.getYCoord();
	}
	
	public void moveX(int x){
		xCoord+=x;
	}
	

	
	public int getX(){
		return xCoord;
	}
	

	public int getY(){
		return yCoord;
	}
	
	public void setCoords(){
			xCoord=loc.getXCoord();
			yCoord=loc.getYCoord();
		
	}
	
	public void putSelfInGrid(Grid gr,Graphics2D g){
		this.g=g;
		this.gr=gr;
		g.setColor(color);

		g.fillRect(xCoord,yCoord, gr.getSize(), gr.getSize());
		g.setColor(Color.BLACK);
		g.drawRect(xCoord,yCoord, gr.getSize(), gr.getSize());

	}
	public void removeSelfFromGrid(){
		xCoord=gr.getGame().getWidth()+1;
		yCoord=gr.getGame().getLength()+1;
	}
	
	public Location getLoc(){
		return loc;
	}
	
	public void setLoc(Location loc){
		this.loc=loc;
	}
	
	public int getXCoord(){
		return xCoord;
	}
	
	public int getYCoord(){
		return yCoord;
	}
	
	public void updateLoc(){
		loc=new Location((xCoord-gr.getXCoord())/gr.getSize(),(yCoord-gr.getYCoord())/gr.getSize(),gr);
	}

	public String toString(){
		return "location:"+loc.toString();
	}
}
